package com.woniuxy.shop.Mapper;

import com.hc.entity.*;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @ClassName LLMapper
 * @Description
 * @Author ll
 * @Date 2022/10/19 14:50
 * @Version 1.0
 **/
@Mapper
public interface LLMapper {

    @Select("select * from hc_agree where id = #{id}")
    Agree test(int id);
    @Select("select * from hc_shop where user_id = #{id}")
    Shop isexitshop(int id);
    @Select("select * from hc_shop where user_id = #{id} and status = 'n' or status = 'y' and user_id = #{id}")
    Shop ispass(int id);
    @Insert("insert into hc_shop (name,picture,description,user_id,province,city,area,address,keyword,status) values (#{name},#{picture},#{description},#{userId},#{province},#{city},#{area},#{address},#{keyword},#{status})")
    void insertshop(Shop shop);
    @Insert("insert into hc_goods (shop_id,description,picture,price,stock,discountprice,status) values (#{shopid},#{description},#{picture},#{price},#{stock},#{discountprice},#{status})")
    void insertgoods(Goods goods);
    @Select("select * from hc_goods where shop_id = #{id} and status = 'y'")
    List<Goods> getmygoods(int id);
    @Select("select * from hc_goods where id = #{id}")
    Goods getgoodsdetail(int id);
    @Update("update hc_goods set stock = #{stock} where id = #{id}")
    void changestock(@Param("id")int id, @Param("stock")int stock);
    @Update("update hc_goods set status = 'x' where id = #{id}")
    void offyheshelf (int id);
    @Select("select * from hc_order where shop_id = #{shopid} and status = 'd'")
    @Results({
            @Result(column = "goods_id",property = "goods",one = @One(select = "com.woniuxy.shop.Mapper.LLMapper.getgoodsdetail"))
    })
    List<Order> finish(int shopid);

    @Select("select * from hc_order where shop_id = #{shopid}")
    @Results({
            @Result(column = "goods_id",property = "goods",one = @One(select = "com.woniuxy.shop.Mapper.LLMapper.getgoodsdetail"))
    })
    List<Order> allorder(int shopid);

    @Select("select * from hc_order where shop_id = #{shopid} and status = 'p'")
    @Results({
            @Result(column = "goods_id",property = "goods",one = @One(select = "com.woniuxy.shop.Mapper.LLMapper.getgoodsdetail"))
    })
    List<Order> notfinish(int shopid);
    @Insert("insert into hc_second_kill (good_id,starttime,num,secprice,shop_id,endtime) values (#{goodsId},#{startTime},#{num},#{secprice},#{shopId},#{endTime})")
    void addsecondkill(Seckill seckill);
    @Insert("insert into hc_discount_type_goods (discount_type_id,goods_id) values (#{discount},#{goodsId})")
    void addGoodsDiscountMid(@Param("discount") int discount,@Param("goodsId")int goodsId);
    @Insert("insert into hc_discount_type (shop_id,name,starttime,endtime,rule) values (#{shopId},#{name},#{startTime},#{endTime},#{rule})")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    void addDiscountType(DiscountType discountType);
    @Update("update hc_shop set status = 'y' where id = #{shopid}")
    void dayang(int shopid);

    @Update("update hc_shop set status = 'n' where id = #{shopid}")
    void openshop(int shopid);
    @Select("select * from hc_shop where user_id = #{id}")
    Shop getshopstatus(int id);
}